<?php
class setupControl extends Control{	
	//配置项，网站信息显示
	public function index(){
		$db = M('config');
		$config = $db->where('tid=1')->all();
		$this->assign('config', $config);		
		$this->display();	
	}
	//公用编辑实现方法
	public function edit(){
		$db = M('config');
		$data = $_POST;
		$_POST = array();
		foreach ($data as $k=>$v){
			$_POST['id']=$k;
			$_POST['value']=$v;
			$db->save();
		}
		$config = $db->field('name,value')->all();
		$resultArr = array();
		foreach ($config as $v){		
			$resultArr[$v['name']]=$v['value'];			
		}
		$resultStr = "<?php \n  if(defined(PATH_HD))exit; \n return  ".var_export($resultArr,true)." \n  ?>";		
		file_put_contents('./config/config.php', $resultStr);
	}
	//验证码配置项
	public function code(){
		$db = M('config');
		$config = $db->where('tid=0')->all();
		$this->assign('config', $config);
		$this->display();
	}
	//缩略图配置项
	public function thumbnail(){
		$db = M('config');
		$config = $db->where('tid=2')->all();
		$this->assign('config', $config);
		$this->display();
	}
	//水印配置项
	public function watermark(){
		$db = M('config');
		$config = $db->where('tid=3')->all();
		$this->assign('config', $config);
		$this->display();		
	}	
}
















?>